package com.example.synatx.datetime;

import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @auth guoxh
 * @date 2020/2/16-下午11:01
 * @desc
 * Duration 类主要用于以秒和纳秒衡量时间长短，所以不能传递两个LocalDate对象做参数
 **/
public class DurationTest {

    public void test01(){
        LocalTime time = LocalTime.now();
        LocalTime time1 = LocalTime.of(12,20,30);

        LocalDateTime dateTime = LocalDateTime.now();
        LocalDateTime dateTime1 = LocalDateTime.of(2020,2,26,10,12,30);

        Instant instant = Instant.now();
        Instant instant1 = Instant.ofEpochSecond(4);

        Duration duration = Duration.between(time,time1);
        Duration duration1 = Duration.between(dateTime,dateTime1);
        Duration duration2 = Duration.between(instant,instant1);
    }
}
